#include <stdio.h>
#include <stdlib.h>

/*
数组没有赋值运算符“=”，必须一个元素一个元素地赋值。

“&a+1”的含义是数组a的最后一个元素的首地址值加1，即数组a后面的地址

a[1]的地址应该是“&a[1]”
a+1就代表a[1]的地址，与&a[1]等效,数组名就是数组存储的首地址，所以a+1代表的是首地址移动到第2个元素存储的首地址

*/

int main()
{
    int i, a[5] = {1, 2, 3, 4, 5}, b[5];
    char ch[] = "good!", st[6];
    for (i = 0; i < 5; i++)
        b[i] = a[i];
    for (i = 0; i < 6; i++)
        st[i] = ch[i];

    for (i = 0; i < 5; i++)
        printf("%d ", b[i]);
    printf("\n");
    printf(b);
    printf("\n");
    printf(st);
    printf("\n");

    // 使用键盘赋值
    for (i = 0; i < 5; i++)
    {
        printf("please input a digital: ");
        scanf("%d", a + i); // 等效 scanf("%d", &a[i]);
    }
    for (i = 0; i < 5; i++)
    {
        printf("%d ", *(a + i)); // 等效printf("%d ",a[i]);
    }
    printf("\n");

    for (i = 0; i < 5; i++)
    {
        printf("please input a char (%d): ", i);
        /*
            The notation "%c\n" means 'read a character;
            then skip following white space until the next character that isn't white space,
            and only then return from the function'.
        */
        scanf("%c\n", ch + i); // 等效 scanf("%c", ch[i]);
    }
    ch[i] = '\0'; // 字符串结束符，覆盖最后一个输入的字符
    printf(ch);
    printf("\n");
    system("pause");
    return 0;
}